<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item v-show="cityShow" label="县区" prop="town">
        <el-select
          v-model="queryParams.city"
          clearable
          placeholder="请选择"
          size="small"
          style="width: 150px"
          @change="selectCity"
        >
          <el-option
            v-for="item in this.cityData"
            :key="item.deptCode"
            :label="item.deptName"
            :value="item.deptCode">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="乡镇" prop="town">
        <el-select
          v-model="queryParams.town"
          clearable
          placeholder="请选择"
          size="small"
          style="width: 150px"
          @change="selectTown"
        >
          <el-option
            v-for="item in this.townData"
            :key="item.deptCode"
            :label="item.deptName"
            :value="item.deptCode">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="村" prop="village">
        <el-select
          v-model="queryParams.village"
          clearable
          placeholder="请选择"
          size="small"
          style="width: 150px"
          @change="selectVillage"
        >
          <el-option
            v-for="item in this.villageData"
            :key="item.deptCode"
            :label="item.deptName"
            :value="item.deptCode">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="发放状态" prop="doneState">
        <el-select
          v-model="queryParams.doneState"
          clearable
          placeholder="请选择"
        >
          <el-option
            v-for="dict in doneState"
            :key="dict.value"
            :label="dict.name"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="收款人" prop="skrmc">
        <el-input
          v-model="queryParams.skrmc"
          placeholder="请输入收款人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年度" prop="yyear">
        <el-date-picker
          v-model="queryParams.yyear"
          value-format="yyyy"
          type="year"
          placeholder="选择预算年度">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <!--<el-col :span="1.5">
        <el-button
          size="mini"
          type="primary" plain
          v-hasPermi="['distribution:distribution:distribution']"
        >
          &lt;!&ndash;          @click="handleBudgetOut"&ndash;&gt;
          <svg-icon class="svg" icon-class="percent"/>
          设置发放比例
        </el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          size="mini"
          type="primary" plain
          @click="handleSave"
          :disabled="multiple"
          v-hasPermi="['distribution:distribution:add']"
          v-preventReClick="2000"
        >
          <svg-icon class="svg" icon-class="save"/>
          生成批次
        </el-button>
        <!--        :disabled="multiple"-->

      </el-col>
      <!--<el-col :span="1.5">
        <el-button
          v-hasPermi="['distribution:distribution:export']"
          icon="el-icon-download"
          size="mini"
          type="warning"
          :disabled="multiple"
          @click="handleExport"
        >导出
        </el-button>
      </el-col>-->
      <!-- <el-col :span="1.5">
         <el-button
           icon="el-icon-edit"
           size="mini"
           v-hasPermi="['distribution:distribution:export']"
         >导出
         </el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button
           icon="el-icon-edit"
           size="mini"
           v-hasPermi="['distribution:distribution:export']"
         >打印
         </el-button>
       </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <!-- <div class="selectedDv" v-if="ids.length > 0">已选<span style="color:#1890ff;padding:  0 6px;">{{ ids.length }}</span>项
     </div>-->
    <el-table v-loading="loadingAdd" :data="budgetData" ref="multipleTable"
              @selection-change="handleCreateSelectionChange" :row-key="getRowKey">
      <el-table-column type="selection" width="55" align="center" :reserve-selection="true"/>
      <el-table-column width="220" label="行政区划" align="center" prop="county">
        <template slot-scope="scope">
          {{ scope.row.xjmc }} - {{ scope.row.zjmc }} - {{ scope.row.cjmc }}
        </template>
      </el-table-column>
      <!--<el-table-column label="县区" align="center" prop="xjmc"/>
      <el-table-column label="乡镇" align="center" prop="zjmc"/>
      <el-table-column label="村" width="120" align="center" prop="cjmc"/>-->
      <el-table-column label="收款人" align="center" prop="skrmc"/>
      <el-table-column label="收款账户" width="200" align="center" prop="skrkh"/>
      <el-table-column label="开户行" width="200" align="center" prop="skrkhh"/>
      <el-table-column label="应发金额（元）" width="150" align="center" prop="totalMoney">
        <template slot-scope="scope">
          {{
            scope.row.totalMoney == 0 ? "-" : (String(scope.row.totalMoney).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(scope.row.totalMoney).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(scope.row.totalMoney).split('.')[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + "." + (String(scope.row.totalMoney).split('.')[1].length < 2 ? String(scope.row.totalMoney).split('.')[1] + '0' : String(scope.row.totalMoney).split('.')[1]))
          }}
        </template>
      </el-table-column>
      <el-table-column label="已发放比例（%）" width="180" align="center" prop="distributeRatio">
        <template slot-scope="scope">
          {{ (scope.row.distributeRatio * 100).toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column label="联系电话" width="120" align="center" prop="lxdh"/>
      <el-table-column label="年份" width="120" align="center" prop="yyear"/>
      <el-table-column label="青苗费（元）" width="100" align="center" prop="price">
        <template slot-scope="scope">
          {{
            scope.row.fzwMoney == 0 ? "-" : (String(scope.row.fzwMoney).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(scope.row.fzwMoney).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(scope.row.fzwMoney).split('.')[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + "." + (String(scope.row.fzwMoney).split('.')[1].length < 2 ? String(scope.row.fzwMoney).split('.')[1] + '0' : String(scope.row.fzwMoney).split('.')[1]))
          }}
        </template>
      </el-table-column>
      <el-table-column label="土地收益金（元）" width="150" align="center" prop="cbfmc">
        <template slot-scope="scope">
          {{
            parseFloat(scope.row.jttdMoney)+parseFloat(scope.row.gytdMoney)==0?"-":String((parseFloat(scope.row.jttdMoney)+parseFloat(scope.row.gytdMoney)).toFixed(2)).split('.')[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')+"."+String((parseFloat(scope.row.jttdMoney)+parseFloat(scope.row.gytdMoney)).toFixed(2)).split('.')[1]
           /* (parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney)) == 0 ? "-" : (String((parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney))).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String((parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney))).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String((parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney))).split('.')[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + "." + (String((parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney))).split('.')[1].length < 2 ? String((parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney))).split('.')[1] + '0' : String((parseFloat(scope.row.jttdMoney) + parseFloat(scope.row.gytdMoney))).split('.')[1]))*/
          }}
        </template>
      </el-table-column>
      <!--      <el-table-column label="地块编码" width="180" align="center" prop="dkbm"/>-->
      <!--      <el-table-column label="面积（亩）" align="center" prop="evaluationArea">-->
      <!--        <template slot-scope="scope">-->
      <!--              <span>{{-->
      <!--                  scope.row.fzwArea-->paymentList
      <!--                }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
    </el-table>
    <!--      :current-page.sync="queryParams.pageNum"-->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit="queryParams.pageSize"
      :page-sizes="[10, 30, 50,100,150,200,250,1000]"
      @pagination="getSList"
    />

    <!--    添加-->
    <el-dialog :title="title" :visible.sync="open" width="1050px" append-to-body @close="cancelCheck">
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="本次发放金额" prop="name">
              {{
                this.money == 0 ? "-" : (String(this.money).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(this.money).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(this.money).split('.')[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + "." + (String(this.money).split('.')[1].length < 2 ? String(this.money).split('.')[1] + '0' : String(this.money).split('.')[1]))
              }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预算总金额" prop="name">
              {{
                this.ysje == 0 ? "-" : (String(this.ysje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(this.ysje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(this.ysje).split('.')[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + "." + (String(this.ysje).split('.')[1].length < 2 ? String(this.ysje).split('.')[1] + '0' : String(this.ysje).split('.')[1]))
              }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="批次号" prop="batchNumber">
          <el-input v-model="form.batchNumber" placeholder="请输入批次号" disabled/>
        </el-form-item>
        <el-form-item label="付款账户" prop="by1">
          <el-select
            style="width: 100%"
            v-model="form.by1"
            @change="selectAcc"
            placeholder="请选择付款账户">
            <el-option
              v-for="item in this.frAccList"
              :key="item.frAccNo"
              :label="`${item.frAccNo}-${item.frAccName}`"
              :value="item.frAccNo">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="付款方名称" prop="by4">
          <el-input v-model="form.by4" placeholder="选择付款账号，自动填充" disabled/>
        </el-form-item>
        <el-form-item label="发放比例（%）" prop="ratio">
          <el-input v-model="form.ratio" placeholder="请输入比例" ref="ratio" type="number"
                    @input="handleRatio"/>
        </el-form-item>
        <!--  <el-form-item label="备注" prop="remarks">
            <el-input v-model="form.remark" type="textarea" placeholder="请输入备注"/>
          </el-form-item>-->
        <el-form-item label="附件" prop="by3">
          <el-upload
            class="avatar-uploader"
            :action="productFileAction"
            :file-list="fileList"
            list-type="picture-card"
            :before-upload="beforeUpload"
            :headers="headers"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :on-success="uploadSuccess"
            :on-exceed="masterFileMax"
            :limit=limit
            multiple
            accept="image/*"
            name="uploadfiles">
            <i class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
          <el-input type="textarea" v-show="1==2" v-model="form.by3" placeholder="请输入附加"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <!--        <el-button @click="handleStatisForAdd">统计发放金额</el-button>-->
        <el-button @click="cancelCheck">取 消</el-button>
        <el-button type="success" @click="submitForm">完 成</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改对话框 -->
    <el-dialog title="批次明细" :visible.sync="openYsmx" width="900px" append-to-body>
      <div style="min-height: 500px">
        <el-table v-loading="loading" :data="detailsList" @selection-change="handleSelectionChange">
          <el-table-column label="合同编码" width="200" align="center" prop="htbm"/>
          <el-table-column label="承包方" align="center" prop="cbfmc"/>
          <el-table-column label="面积（亩）" align="center" prop="evaluationArea">
            <template slot-scope="scope">
              <span>{{
                  scope.row.evaluationArea / 2
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="金额（元）" align="center" prop="money">
            <template slot-scope="scope">
              {{
                scope.row.money == 0 ? "-" : (String(scope.row.money).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(scope.row.money).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(scope.row.money).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'))
              }}
            </template>
          </el-table-column>
          <el-table-column label="收款方" align="center" prop="skrmc"/>
          <el-table-column label="收款账号" align="center" prop="skrkh">
            <template slot-scope="scope">
              {{ scope.row.skrkh ? scope.row.skrkh.replace(/^(\d{4})\d+(\d{4})$/, "$1******$2") : "" }}
            </template>
          </el-table-column>
          <el-table-column label="流水号" align="center" prop="orderNumber"/>
          <el-table-column label="发放状态" align="center" prop="by2">
            <template slot-scope="scope">
              {{ scope.row.by2 == "0" ? "待发放" : scope.row.by2 == "1" ? "发放成功" : "" }}
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="handlePay(scope.row)"
                v-hasPermi="['distribution:distribution:remove']"
              >
                <svg-icon class="svg" icon-class="details"/>
                付款信息
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination
        v-show="detailstotal>0"
        :total="detailstotal"
        :page.sync="queryDetailsParams.pageNum"
        :limit.sync="queryDetailsParams.pageSize"
        @pagination="getDetails"
      />
    </el-dialog>
    <el-dialog title="审核记录" :visible.sync="openShjl" width="800px" append-to-body>
      <div style="min-height: 484px">
        <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange">
          <el-table-column label="审核人" align="center" prop="approvalPersonalName"/>
          <el-table-column label="审核时间" align="center" prop="approvalTime"/>
          <el-table-column label="审核状态" align="center" prop="state">
            <template slot-scope="scope">
              <div class="statusDv">
                <div class="statudPoint" :class="'Bg'+scope.row['state']"></div>
                <div v-for="sta in budgetStatus" v-if="sta.dictValue == scope.row['state']">{{ sta.dictLabel }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="审核意见" align="center" prop="by1"/>
        </el-table>
      </div>
      <pagination
        v-show="recordtotal>0"
        :total="recordtotal"
        :page.sync="querybudgetFundsOutParams.pageNum"
        :limit.sync="querybudgetFundsOutParams.pageSize"
        @pagination="getRecordList"
      />
    </el-dialog>

    <!--    审核-->
    <el-dialog :title="title" :visible.sync="opensp" width="1000px" append-to-body>
      <el-steps :active="activeCheck" finish-status="success" align-center style="margin-bottom: 20px">
        <el-step title="步骤 1"></el-step>
        <el-step title="步骤 2"></el-step>
      </el-steps>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" v-if="activeCheck == 1">
        <!--<el-row>
          <el-col :span="12">
            <el-form-item label="已签合同金额" prop="number">
              {{ this.yqhtje == 0 ? "-" : String(parseInt(this.yqhtje)).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="新增合同金额" prop="name">
              {{ this.xzhtje == 0 ? "-" : String(parseInt(this.xzhtje)).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') }}
            </el-form-item>
          </el-col>
        </el-row>-->
        <el-row>
          <el-col :span="12">
            <el-form-item label="本次发放金额" prop="name">
              {{
                this.bcffje == 0 ? "-" : (String(this.bcffje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(this.bcffje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(this.bcffje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'))
              }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预算总金额" prop="name">
              {{
                this.ysje == 0 ? "-" : (String(this.ysje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,').split('.').length < 2 ? String(this.ysje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + ".00" : String(this.ysje).replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'))
              }}
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="复审状态" prop="state" required>
          <!-- <el-select
             v-model="form.state"
             clearable
             placeholder="请选择"
             size="small"
             style="width: 100%"
           >
             <el-option
               v-for="dict in approveStatus"
               :key="dict.dictValue"
               :label="dict.dictLabel"
               :value="dict.dictValue">
             </el-option>
           </el-select>-->

          <el-radio-group v-model="form.state">
            <el-radio v-for="item in approveStatus"
                      border
                      size="medium"
                      :label="item.dictValue">
              {{ item.dictLabel }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="复审意见" prop="remark">
          <el-input type="textarea" v-model="form.remark" placeholder="请输入复审意见"/>
        </el-form-item>
      </el-form>
      <div v-else>
        <el-form :model="querypgParams" ref="querypgForm" :inline="true" v-show="showSearch">
          <el-form-item label="县区" prop="city" v-show="cityShow">
            <el-select
              v-model="querypgParams.city"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectCity"
            >
              <el-option
                v-for="item in this.cityData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="乡镇" prop="town" v-show="townShow">
            <el-select
              v-model="querypgParams.town"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectTown"
            >
              <el-option
                v-for="item in this.townData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="村" prop="village" v-show="villageShow">
            <el-select
              v-model="querypgParams.village"
              clearable
              placeholder="请选择"
              size="small"
              @change="selectVillage"
            >
              <el-option
                v-for="item in this.villageData"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="承包方" prop="name">
            <el-input
              v-model="querypgParams.cbfmc"
              placeholder="请输入承包方"
              clearable
              size="small"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="mini" @click="handlePgQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetPgQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="pgList">
          <el-table-column label="承包方" align="center" prop="cbfmc"/>
          <el-table-column label="面积（亩）" align="center" prop="evaluationArea">
            <template slot-scope="scope">
              <span>{{
                  scope.row.evaluationArea / 2
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="金额（元）" align="center" prop="money">
            <template slot-scope="scope">
              <span>{{
                  scope.row.money == 0 ? "-" : scope.row.money.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
                }}</span>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="pgtotal>0"
          :total="pgtotal"
          :page.sync="querypgParams.pageNum"
          :limit.sync="querypgParams.pageSize"
          @pagination="getPgList"
        />
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelsp">取 消</el-button>
        <el-button type="primary" @click="presChecksp" v-if="activeCheck == 1">上一步</el-button>
        <el-button type="primary" @click="nextChecksp" v-if="activeCheck == 0">下一步</el-button>
        <el-button type="success" @click="submitFormsp" v-if="activeCheck == 1">完 成</el-button>
      </div>


      <el-form ref="form" :model="form" :rules="rules" label-width="95px">

      </el-form>
    </el-dialog>

    <!--    签字凭证-->
    <el-dialog :title="title" :visible.sync="openqzpz" width="700px" append-to-body @close="cancel">
      <el-form ref="form1" :model="form1" :rules="rules1" label-width="100px">
        <el-form-item label="上传签字凭证" prop="by3">
          <!--          :before-remove="beforeRemove"-->
          <el-upload
            class="avatar-uploader"
            :action="productFileAction"
            :file-list="fileList"
            list-type="picture-card"
            :before-upload="beforeUpload"
            :headers="headers"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :on-success="uploadSuccess"
            :limit=5
            multiple
            accept="image/jpeg,image/jpg,image/png"
            name="uploadfiles">
            <i class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>


          <!-- <el-upload
             class="avatar-uploader"
             list-type="picture-card"
             :file-list="fileList"
             :action="productFileAction"
             :before-upload="beforeUpload"
             :headers="headers"
             :on-preview="handlePreview"
             :on-remove="handleRemove"
             :onSuccess="uploadSuccess"
             multiple
             accept="image/*"
             name="uploadfiles">
             <i class="el-icon-plus avatar-uploader-icon"></i>
           </el-upload>-->
          <el-input type="textarea" v-show="1==2" v-model="form1.by3" placeholder="请输入附加"/>
          <!--          <el-input type="textarea" v-model="form1.by3" placeholder="请输入附加"/>-->
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitQzpzForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--    验证码-->
    <el-dialog :title="title" :visible.sync="openyzm" width="500px" append-to-body @close="cancel">
      <el-form ref="form1" :model="form1" :rules="rules1" label-width="100px">
        <el-form-item label="验证码" prop="by3">
          <el-input placeholder="请输入验证码" v-model="form1.code"></el-input>
          <button @click.prevent="getVerifyCode()" class="code-btn" :disabled="!show">
            <span v-show="show">获取验证码</span>
            <span v-show="!show" class="count">{{ count }} s</span>
          </button>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitYzmForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>

  </div>
</template>

<script>
import {
  approvalMoneyOut,
  approvalOut,
  approvalOutList,
  certificate, checkForNewCpsDistribution,
  delBudgetFundsOut,
  distribution,
  distributionExport,
  getdistribution,
  mxListOut,
  newCpsDistribution,
  paymentList,
  queryPay,
  sendSmsVerifyCode,
  statisForAdd,
  statisMoneyForAdd,
  subApprovalOutList,
  verifySmsVerifyCode
} from "@/api/zjgl/budgetFundsOut";
import {listAccount} from "@/api/zjgl/account";
import {childlistUse} from "@/api/system/dept";
import {getInfo} from "@/api/login";
import {getCode} from "@/api/htgl/CBHT";
import {getToken} from "@/utils/auth";
import preventReClick from '@/utils/plugins.js'
import {MessageBox} from "element-ui";
import store from "@/store";

export default {
  name: "BudgetFunds",
  data() {
    return {
      dialogVisible: false,
      dialogImageUrl: '',
      EvaluationAccountingList: [],
      fileList: [],
      headers: {Authorization: 'Bearer ' + getToken()},
      productFileAction: process.env.VUE_APP_BASE_API + '/system/resource/profile/upload',
      imageTempList: [],
      imageList: "",
      limit: 5,
      productfileList: [],
      CBFList: [],
      field101Action: 'https://jsonplaceholder.typicode.com/posts/',
      field101fileList: [],
      openCheck: false,
      openBudget: false,
      openYsmx: false,
      openShjl: false,
      statusOptions: [],
      budgetStatus: [],
      doneState: [{
        name: "未发放",
        value: "0"
      }, {
        name: "部分发放",
        value: "1"
      }],
      approveStatus: [],
      pgList: [],
      recordList: [],
      detailsList: [],
      budgetData: [],
      frAccList: [],
      cityData: [],
      townData: [],
      villageData: [],
      cityShow: '',
      townShow: '',
      villageShow: '',
      bcffje: 0,
      xzhtje: 0,
      yqhtje: 0,
      ysje: 0,
      count: 60,
      money: 0,
      temmoney: 0,
      show: true,
      cookiePassword: "",
      distributeId: '',
      selectedBudgetDataIds: [],
      selectedBudgetDataStringIds: "",
      activeCheck: 0,
      active: 0,
      // 遮罩层
      loading: false,
      loadingAdd: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      detailstotal: 0,
      cbfbms: [],
      totalbudget: 0,
      pgtotal: 0,
      recordtotal: 0,
      // 【请填写功能名称】表格数据222
      BudgetFundsList: [],
      departmentCode: '',
      querypgParams: {
        pageNum: 1,
        pageSize: 10,
        cbfmc: null,
        departmentCode: null,
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      opensp: false,
      openqzpz: false,
      openyzm: false,
      querybudgetFundsOutParams: {
        pageNum: 1,
        pageSize: 10,
        distributionId: null,
        departmentCode: null,
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        distributeId: null,
        batchNumber: null,
        state: null,
        skrmc: null,
        yyear: null,
        name: null,
        doneState: null,
        status: null,
        departmentCode: null,
        dkbm: null,
        town: null,
        village: null,
        city: null,
      },
      queryBudgetParams: {
        pageNum: 1,
        pageSize: 1,
        distributionIds: [],
        departmentCode: null,
        name: null,
        cbfmc: null,
        year: null,
        sdate: null,
        edate: null,
        status: null,
        town: null,
        village: null,
      },
      queryDetailsParams: {
        pageNum: 1,
        pageSize: 10,
        distributionId: "",
        name: null,
        year: null,
        sdate: null,
        edate: null,
        status: null,
      },
      options: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }, {
        value: '选项3',
        label: '蚵仔煎'
      }, {
        value: '选项4',
        label: '龙须面'
      }, {
        value: '选项5',
        label: '北京烤鸭'
      }],
      value1: [],
      value2: [],
      // 表单参数
      form: {},
      form1: {},
      // 表单校验
      rules: {
        batchNumber: [
          {required: true, message: "批次号不能为空", trigger: "blur"}
        ],
        ratio: [
          {required: true, message: "发放比例不能为空", trigger: "blur"},
        ],
        by1: [
          {required: true, message: "付款账户不能为空", trigger: "blur"}
        ],
        by4: [
          {required: true, message: "收款方名称不能为空", trigger: "blur"}
        ],
      },
      rules1: {
        by3: [
          {required: false, message: "签字凭证不能为空", trigger: "blur"}
        ],
        code: [
          {required: true, message: "验证码不能为空", trigger: "blur"}
        ],
      },
      rules2: {
        code: [
          {required: false, message: "不能为空", trigger: "blur"}
        ],
      }
    };
  },
  created() {
    // this.queryParams.doneState = this.doneState[0].value;
    this.queryParams.yyear = String(new Date().getFullYear());
    this.getDicts('sys_distribution_item_status').then(response => {
      this.statusOptions = response.data
    })
    this.getDicts('sys_budget_status').then(response => {
      this.budgetStatus = response.data
    })
    this.getDicts('sys_approve_status').then(response => {
      this.approveStatus = response.data
    })
    this.getList();
  },
  methods: {
    masterFileMax(files, fileList) {
      this.$message.warning(`最多只允许上传 ${this.limit} 个附件。`);
    },
    handleRemove(file, fileList) {
      let _this = this;
      let url = "";
      let htfj = this.form1.by3;
      if (file.url.indexOf("blob:") > -1) {
        url = file.response.data[0];
        htfj = htfj.split(',');
        let newhtfj = '';
        htfj.forEach((item, i) => {
          if (item.indexOf(url) < 0) {
            if (newhtfj == "") {
              newhtfj = item;
            } else {
              newhtfj = newhtfj + "," + item;
            }
          }
        });
        _this.imageList = newhtfj;
        _this.form1.by3 = newhtfj;
      } else {
        url = file.url;
        htfj = htfj.split(',');
        let newhtfj = '';
        htfj.forEach((item, i) => {
          if (item.indexOf(url) < 0) {
            if (newhtfj == "") {
              newhtfj = item;
            } else {
              newhtfj = newhtfj + "," + item;
            }
          }
        });
        _this.imageList = newhtfj;
        _this.form1.by3 = newhtfj;
      }
    },
    handlePreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    beforeUpload(file) {
      // 图片显示前做一下判断
      let isJPG = /^image\/(jpeg|png|jpg)$/.test(file.type);
      const isLt5M = file.size / 1024 / 1024 < 5;
      if (!isJPG) {
        this.$message.error('上传图片格式不对!');
      }
      if (!isLt5M) {
        this.$message.error('上传头像图片大小不能超过 5MB!');
      }
      return isJPG && isLt5M;
    },
    uploadSuccess(response, file, fileList) {
      if (response.code == 200) {
        let url = process.env.VUE_APP_BASE_API + response.data[0];
        let imageInfo = {name: file.name, url: url};
        this.imageTempList.push(imageInfo);
        if (this.imageList == "") {
          this.imageList = this.imageList + url;
          this.form.by3 = this.imageList;
        } else {
          this.imageList = this.imageList + "," + url;
          this.form.by3 = this.imageList;
        }
        this.timer = setInterval(this.getImageList(fileList), 500);
      } else {
        this.$message.error(response.msg)
      }
    },
    getImageList(fileList) {
      if (this.imageTempList.length == fileList.length) {
        this.fileList = this.imageTempList;
        clearInterval(this.timer);
      }
    },
    selectAcc(val) {
      this.frAccList.map((item) => {
        if (val == item.frAccNo) {
          this.form.by4 = item.frAccName;
        }
      });
    },
    // 选择县
    selectCity(val) {
      this.queryParams.departmentCode = val;
      this.city = val;
      if (val != "" && val != null) {
        childlistUse(val).then(response => {
          this.townData = response.data;
        });
      }
    },
    // 选择镇
    selectTown(val) {
      this.queryParams.dkbm = val;
      if (val != "" && val != null) {
        childlistUse(val).then(response => {
          this.villageData = response.data;
        });
      }
    },
    // 选择村
    selectVillage(val) {
      this.queryParams.dkbm = val;
    },
    checkboxT(row, rowIndex) {
      if (row.by2 == 1) {
        return false;//禁用
      } else {
        return true;//不禁用
      }
    },
    handleExamineRecord(row) {
      this.openShjl = true;
      this.querybudgetFundsOutParams.distributionId = row.distributeId;
      //获取明细信息
      approvalOutList({
        distributionId: row.distributeId,
        pageNum: this.querybudgetFundsOutParams.pageNum,
        pageSize: this.querybudgetFundsOutParams.pageSize
      }).then(response => {
        this.recordList = response.rows;
        this.recordtotal = response.total;
      });
    },
    handleQzpz(row) {
      this.reset();
      this.distributeId = row.distributeId;
      if (row.by3 != "" && row.by3 != undefined && row.by3 != null) {
        this.imageList = row.by3
        row.by3.split(',').forEach((item, i) => {
          let name = item.split('/')[item.split('/').length - 1];
          let imageInfo = {name: name, url: item};
          this.fileList.push(imageInfo);
        });
        this.form1.by3 = row.by3;
      }
      this.openqzpz = true;
    },
    getRecordList() {
      approvalOutList({
        budgetId: this.querybudgetFundsOutParams.distributionId,
        pageNum: this.querybudgetFundsOutParams.pageNum,
        pageSize: this.querybudgetFundsOutParams.pageSize
      }).then(response => {
        this.recordList = response.rows;
        this.recordtotal = response.total;
      });
    },
    presChecksp() {
      if (this.activeCheck-- > 2) this.activeCheck = 0;
    },
    nextChecksp() {
      if (this.activeCheck++ > 2) this.activeCheck = 0;
    },
    submitFormsp() {
      if (this.form.state == "3" && (this.form.remark == "" || this.form.remark == null || this.form.remark == undefined)) {
        this.$message.warning("审核意见不可为空");
        return false;
      }
      approvalOut({distributionIds: this.ids, state: this.form.state, by1: this.form.remark}).then(response => {
        if (response.code == "200") {
          this.msgSuccess("操作成功");
          this.opensp = false;
          this.getList();
        } else {
          this.msgError(response.msg);
        }
      });
    },
    // 取消按钮
    cancelsp() {
      this.opensp = false;
      this.reset();
    },
    childlist(deptCode) {
      childlistUse(deptCode).then(response => {
        this.townData = response.data;
      });
    },
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      // 获取明细
      this.loadingAdd = true;
      this.queryBudgetParams.distributionIds = [];
      this.queryBudgetParams.distributionId = "";
      this.getSList();
      getInfo().then(response => {
        let deptCode = response.user.dept.deptCode;
        if (deptCode.length == 4) {//新区
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.cityData = response.data;
          });
        } else if (deptCode.length == 6) {//县
          this.cityShow = false;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.townData = response.data;
          });
        } else if (deptCode.length == 9) {//镇
          this.cityShow = false;
          this.townShow = false;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.villageData = response.data;
          });
        } else {
          this.childlist(1306);
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
        }
      });
      /*listBudgetFundsOut(this.queryParams).then(response => {
        this.BudgetFundsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });*/
    },
    getRowKey: function (row) {
      return row.paymentId;
    },
    handleSizeChange(v) {
      console.log(v)
    },
    handleRatio(val) {

      if (val != null && val != "" && val != undefined) {
        if (val > 0 && val <= 100) {
          let money = this.temmoney;
          let ratio = val;
          this.money = parseFloat(money * ratio / 100).toFixed(2);
        } else {
          this.$message.warning("发放比例只允许在0-100之间");
          this.form.ratio = 100;
          let money = this.temmoney;
          this.money = money;
        }
      } else {
        this.money = 0;
      }
    },
    getSList(v) {
      if (v) {
        this.queryParams.pageNum = v.page;
        this.queryParams.pageSize = v.limit;
      } else {
        this.queryParams.pageNum = 1;
        // this.queryParams.pageSize = v.limit;
      }
      let doneState = '';
      if (this.queryParams.doneState == "" || this.queryParams.doneState == null) {
        doneState = '3';
      } else {
        doneState = this.queryParams.doneState;
      }
      let yyear = this.queryParams.yyear;
      if (yyear == '' || yyear == null) {
        this.queryParams.yyear = String(new Date().getFullYear());
      }

      paymentList({
        pageNum: this.queryParams.pageNum,
        pageSize: this.queryParams.pageSize,
        dkbm: this.queryParams.dkbm,
        doneState: doneState,
        yyear: this.queryParams.yyear,
        skrmc: this.queryParams.skrmc
      }).then(response => {
        this.loadingAdd = false;
        this.budgetData = response.rows;
        this.total = response.total;
        response.rows.forEach(row => {
          if (this.selectedBudgetDataStringIds.indexOf(row.paymentId) > -1) {
            this.$refs.multipleTable.toggleRowSelection(row);
          }
        });
      });

    },
    pres() {
      if (this.active-- > 2) this.active = 0;
    },
    next() {
      if (this.active++ > 2) this.active = 0;
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.openqzpz = false;
      this.openyzm = false;
      this.fileList = [];
      this.imageList = "";
      this.form1.by3 = "";
      this.active = 0
      this.reset();
    },
    cancelCheck() {
      this.open = false;
      this.openCheck = false;
      this.activeCheck = 0
      this.money = 0;
      this.temmoney = 0;
      this.fileList = [];
      this.ids = [];
      this.queryBudgetParams.distributionId = '';
      this.distributeId = '';
      this.resetForm("queryBudgetForm");
      this.queryBudgetParams.departmentCode = '';

      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        distributeId: null,
        batchNumber: null,
        cbfbms: null,
        remark: null,
        by1: null,
        by3: null,
        by4: null,
        money: null,
        state: null,
        ysje: null,
        ratio: null
      };
      this.resetForm("form");
      this.form1 = {
        distributeId: null,
        by1: null,
        by3: null,
        code: null,
      };
      this.resetForm("form1");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      // this.getList();
      this.getSList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.pageNum = 1;
      this.queryParams.dkbm = "";
      this.handleQuery();
    },
    handlePgQuery() {
      this.querypgParams.pageNum = 1;
      this.getPgList();
    },
    /** 重置按钮操作 */
    resetPgQuery() {
      this.resetForm("querypgForm");
      this.querypgParams.departmentCode = "";
      this.querypgParams.cbfmc = "";
      this.handlePgQuery();
    },
    handleBudgetQuery() {
      this.queryBudgetParams.pageNum = 1;
      this.getSList();
    },
    resetBudgetQuery() {
      this.resetForm("queryBudgetForm");
      this.queryBudgetParams.departmentCode = '';
      this.handleBudgetQuery();
    },
    handleCreateSelectionChange(selection) {
      this.selectedBudgetDataIds = selection.map(item => item.paymentId);
      this.multiple = !selection.length;
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.distributeId);
      this.queryBudgetParams.distributionIds = this.ids;
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增";
      // 获取明细
      this.loadingAdd = true;
      this.queryBudgetParams.distributionIds = [];
      this.queryBudgetParams.distributionId = "";
      this.getSList();
      getInfo().then(response => {
        let deptCode = response.user.dept.deptCode;
        if (deptCode.length == 4) {//新区
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.cityData = response.data;
          });
        } else if (deptCode.length == 6) {//县
          this.cityShow = false;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.townData = response.data;
          });
        } else if (deptCode.length == 9) {//镇
          this.cityShow = false;
          this.townShow = false;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.villageData = response.data;
          });
        } else {
          this.childlist(1306);
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
        }
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.open = true
      this.title = "修改";
      this.reset();
      const id = row.distributeId;
      this.distributeId = id;
      this.ids = id;
      // 获取明细
      this.loadingAdd = true;
      this.queryBudgetParams.distributionIds = [];
      this.queryBudgetParams.distributionId = id;
      getdistribution({distributeId: id}).then(response => {
        this.selectedBudgetDataStringIds = response.data.by5;
        this.selectedBudgetDataIds = response.data.by5.split(",");
        this.form.batchNumber = response.data.batchNumber;
        this.form.by4 = response.data.by4;
        this.form.by1 = response.data.by1;
        this.form.remark = response.data.remark;
        this.getSList();
      });
      getInfo().then(response => {
        let deptCode = response.user.dept.deptCode;
        if (deptCode.length == 4) {//新区
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.cityData = response.data;
          });
        } else if (deptCode.length == 6) {//县
          this.cityShow = false;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.townData = response.data;
          });
        } else if (deptCode.length == 9) {//镇
          this.cityShow = false;
          this.townShow = false;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.villageData = response.data;
          });
        } else {
          this.childlist(1306);
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      // let paymentIds = this.$refs.multipleTable.selection.map(item => item.paymentId);
      let paymentIds = this.selectedBudgetDataIds;
      let ratio = this.form.ratio / 100;
      let _this=this;
      this.$refs["form"].validate(valid => {
        if (valid) {
          checkForNewCpsDistribution({
            paymentIds: paymentIds,
            ratio: ratio,
          }).then(response => {
            if(response.data.length>=1)
            {
              MessageBox.confirm('您设置的发放比例高于资金剩余可发放比例，请重新设置', '系统提示', {
                  confirmButtonText: '确认',
                  cancelButtonText: '取消',
                  type: 'warning',
                showConfirmButton:false,
                showCancelButton:false,
                }
              ).then(() => {
                newCpsDistribution({
                  paymentIds: paymentIds,
                  ratio: ratio,
                  by1: this.form.by1,
                  by4: this.form.by4,
                  by3: this.form.by3,
                  remark: this.form.remark
                }).then(response => {
                  this.msgSuccess("保存成功");
                  this.open = false;
                  this.money = 0;
                  this.fileList = [];
                  this.temmoney = 0;
                  this.selectedBudgetDataIds = [];
                  this.$refs.multipleTable.clearSelection()
                  this.getList();
                });
              })
            }
            else {
              newCpsDistribution({
                paymentIds: paymentIds,
                ratio: ratio,
                by1: this.form.by1,
                by4: this.form.by4,
                by3: this.form.by3,
                remark: this.form.remark
              }).then(response => {
                this.msgSuccess("保存成功");
                this.open = false;
                this.money = 0;
                this.fileList = [];
                this.temmoney = 0;
                this.selectedBudgetDataIds = [];
                this.$refs.multipleTable.clearSelection()
                this.getList();
              });
            }
          });


        }
      });
    },
    submitYzmForm() {
      let _this = this;
      this.$refs["form1"].validate(valid => {
        if (valid) {
          verifySmsVerifyCode({verifyCode: this.form1.code}).then(response => {
            if (response.code == 200 && response.msg == "验证成功") {
              const loading = _this.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
              });
              distribution({distributeIds: ids}).then(response => {
                loading.close();
                _this.getList();
                _this.openyzm = false;
                if (response.code == 200) {
                  _this.msgSuccess("操作成功");
                } else {
                  _this.msgInfo(response.msg);
                }
              });
            } else {
              _this.msgInfo(response.msg);
            }
          });
        }
      });
    },
    submitQzpzForm() {
      this.$refs["form1"].validate(valid => {
        if (valid) {
          if (this.distributeId != "" && this.distributeId != undefined && this.distributeId != null) {
            this.form1.distributeId = this.distributeId;
            certificate(this.form1).then(response => {
              this.msgSuccess("操作成功");
              this.openqzpz = false;
              this.imageList = "";
              this.fileList = [];
              this.getList();
            });
          } else {
            this.$message.warning("操作有误，请重新操作");
          }
          /*if (this.form.distributeId != null) {
            updateBudgetFunds(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            this.form.cbfbms = this.cbfbms;
            addBudgetFundsOut(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }*/
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.distributeId || this.ids;
      this.$confirm('是否确认删除数据项?', "警告", {
        cancelButtonClass: 'btn-custom-cancel',
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delBudgetFundsOut(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    handleCheck(row) {
      this.opensp = true;
      this.title = "审核";
      getInfo().then(response => {
        let deptCode = response.user.dept.deptCode;
        if (deptCode.length == 4) {//新区
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.cityData = response.data;
          });
        } else if (deptCode.length == 6) {//县
          this.cityShow = false;
          this.townShow = true;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.townData = response.data;
          });
        } else if (deptCode.length == 9) {//镇
          this.cityShow = false;
          this.townShow = false;
          this.villageShow = true;
          childlistUse(deptCode).then(response => {
            this.villageData = response.data;
          });
        } else {
          this.childlist(1306);
          this.cityShow = true;
          this.townShow = true;
          this.villageShow = true;
        }
      });

      this.getPgList();
      this.queryDetailsParams.distributionId = row.distributeId;
      approvalMoneyOut({distributionIds: this.ids}).then(response => {
        this.xhtje = response.data.xzhtje;
        this.yqhtje = response.data.yqhtje;
        this.bcffje = response.data.bcffje;
        this.ysje = response.data.ysje;
      });
    },
    handleDetails(row) {
      this.queryDetailsParams.distributionId = row.distributeId;
      this.openYsmx = true;
      this.title = "批次明细";
      this.getDetails();
    },
    handlePay(row) {
      let orderNumber = row.orderNumber;
      this.openYsmx = true;
      this.title = "付款信息";
      if (orderNumber == "" || orderNumber == undefined || orderNumber == null) {
        this.$message.warning("未发放");
        return;
      }
      queryPay(orderNumber).then(response => {
        if (response.code == 200) {
          this.msgSuccess(response.data.body.dealInfo);
        } else {
          this.$message.warning(response.msg);
        }
      });
    },
    getDetails() {
      mxListOut(this.queryDetailsParams).then(response => {
        this.detailsList = response.rows;
        this.detailstotal = response.total;
        this.loading = false;
      });
    },
    getPgList() {
      subApprovalOutList({
        distributionIds: this.queryBudgetParams.distributionIds,
        cbfmc: this.querypgParams.cbfmc,
        departmentCode: this.querypgParams.departmentCode
      }, this.queryBudgetParams.pageNum, this.queryBudgetParams.pageSize).then(response => {
        this.pgList = response.rows;
        this.pgtotal = response.total;
        this.loading = false;
      });
    },
    getVerifyCode() {
      sendSmsVerifyCode().then((res) => {
        // 验证码倒计时
        if (!this.timer) {
          this.count = 60;
          this.show = false;
          this.timer = setInterval(() => {
            if (this.count > 0 && this.count <= 60) {
              this.count--;
            } else {
              this.show = true;
              clearInterval(this.timer);
              this.timer = null;
            }
          }, 1000);
        }
      });
    },
    handleSave() {
      this.reset();
      // this.form.ratio = 100;
      listAccount().then(response => {
        this.frAccList = response.rows;
      });
      // let cbfbms = this.$refs.multipleTable.selection.map(item => item.paymentId);
      let cbfbms = this.selectedBudgetDataIds;
      if (cbfbms.length < 1) {
        this.$message.warning("请先选择数据");
      } else if (cbfbms.length > 500) {
        this.$message.warning("只允许选择500条数据");
      } else {
        getCode().then(response => {
          this.form.batchNumber = response.msg;
        });
        this.cbfbms = cbfbms;
        this.open = true;
        statisMoneyForAdd({paymentIds: cbfbms.toString()}).then(response => {
          this.money = response.data.totalPaymentMoney;
          this.temmoney = response.data.totalPaymentMoney;
          this.ysje = response.data.totalBudgetMoeny;
        });
        /*totalMoney({cbfbms: cbfbms}).then(response => {

          this.form.money = response.data.bcffje;
          this.form.ysje = response.data.ysje;
        });*/
      }
    },
    handleStatisForAdd() {
      // let cbfbms = this.$refs.multipleTable.selection.map(item => item.paymentId);
      let cbfbms = this.selectedBudgetDataIds;
      let ratio = this.form.ratio / 100;
      statisForAdd({paymentIds: cbfbms, ratio: ratio}).then(response => {

      });
    },
    handleBudgetOut() {
      let ids = this.ids;
      this.title = "获取验证码";
      let _this = this;

      this.$confirm('是否确认发放?', "警告", {
        cancelButtonClass: 'btn-custom-cancel',
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        _this.openyzm = true;
        /*const loading = _this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        sendSmsVerifyCode().then(response => {
          loading.close();
          _this.getList();
          if (response.code == 200) {
            _this.msgSuccess("操作成功");
          } else {
            _this.msgInfo(response.msg);
          }
          /!*distribution({distributeIds: ids}).then(response => {
            loading.close();
            _this.getList();
            if (response.code == 200) {
              _this.msgSuccess("操作成功");
            } else {
              _this.msgInfo(response.msg);
            }
          });*!/
        });*/
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      let _this = this;
      let ids = this.ids;
      this.$confirm('是否确认导出资金发放数据项?', "警告", {
        cancelButtonClass: 'btn-custom-cancel',
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        ids.forEach((item) => {
          distributionExport({distributionId: item}).then(response => {
            _this.download(response.msg);
          });
        })
        /* return distributionExport({distributionId: ids}).then(response => {

           this.download(response.msg);
         });*/
      })
    },
  }
};
/*.then(response => {

  this.download(response.msg);
})*/
</script>
<style>
/* 短信验证码css */
.pr {
  position: relative;
}

.code-btn {
  width: 100px;
  height: 20px;
  position: absolute;
  top: 10px;
  right: 5px;
  z-index: 222;
  color: #ef8466;
  font-size: 14px;
  border: none;
  border-left: 1px solid #bababa;
  padding-left: 10px;
  background-color: #fff;
  cursor: pointer;
}

.btn-custom-cancel {
  float: right;
  margin-left: 10px;
}

.selectedDv {
  background-color: rgba(230, 247, 255, 1);
  box-sizing: border-box;
  border-width: 1px;
  border-style: solid;
  border-color: rgba(186, 231, 255, 1);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
}

.statusDv {
  display: flex;
  justify-content: center;
  align-items: center;
}

.statudPoint {
  border-radius: 50px;
  width: 6px;
  height: 6px;
  margin-right: 6px;
}

/*审核通过背景色*/
.Bg2 {
  background-color: #13ce66;
}

/*未提交*/
.Bg0 {
  background-color: #1890ff;
}

/*待审核*/
.Bg1 {
  background-color: orange;
}

/*审核失败*/
.Bg3 {
  background-color: red;
}

.myTitle {
  margin: 10px 0;
  color: #1890FF;
  font-size: 16px;
}
</style>
